\subsection{TGA}
class TGA {\\
\hspace{10pt}    public:\\

\hspace{10pt}    TGA(const char *filename);\\

\hspace{10pt}    int width;\\
\hspace{10pt}	 int height;\\
\hspace{10pt}    unsigned char byteCount;\\
\hspace{10pt}    unsigned char* data;\\
	
\hspace{10pt}	pair$<$ int, int $>$ getMax();\\
\hspace{10pt}	int getRadio();\\
\hspace{10pt}	pair$<$ int, int $>$ getCentro(int);\\
\hspace{10pt}	int* getPixel(int i, int j);\\
};\\



TGA::TGA(const char *filename){\\
\hspace{10pt}    FILE *file;\\
\hspace{10pt}	unsigned char type[4];\\
\hspace{10pt}	unsigned char info[6];\\

\hspace{10pt}    file = fopen(filename, "rb");\\

\hspace{10pt}    if (!file){\\
\hspace{10pt}\hspace{10pt}		return;\\
\hspace{10pt}	}\\

\hspace{10pt}	fread ($\&$type, sizeof (char), 3, file);\\
\hspace{10pt}	fseek ($file, 12, SEEK_SET$);\\
\hspace{10pt}	fread ($\&$info, sizeof (char), 6, file);\\

\hspace{10pt}	//image type either 2 (color) or 3 (greyscale)\\
\hspace{10pt}	if (type[1] != 0 || (type[2] != 2 $\&$$\&$ type[2] != 3))\\
\hspace{10pt}	{\\
\hspace{10pt}\hspace{10pt}		fclose(file);\\
\hspace{10pt}\hspace{10pt}		return;\\
\hspace{10pt}	}\\

\hspace{10pt}	this-$>$width = info[0] + info[1] * 256;\\
\hspace{10pt}	this-$>$height = info[2] + info[3] * 256;\\
\hspace{10pt}	this-$>$byteCount = info[4] / 8;\\

\hspace{10pt}	if (this-$>$byteCount != 3 $\&$$\&$ this-$>$byteCount != 4) {\\
\hspace{10pt}\hspace{10pt}		fclose(file);\\
\hspace{10pt}\hspace{10pt}		return;\\
\hspace{10pt}	}\\

\hspace{10pt}	long imageSize = this-$>$width * this-$>$height * this-$>$width * this-$>$byteCount;\\

\hspace{10pt}	//allocate memory for image data\\
\hspace{10pt}	this-$>$data = new unsigned char[imageSize];\\

\hspace{10pt}	//read in image data\\
\hspace{10pt}	fread(this-$>$data, sizeof(unsigned char), imageSize, file);\\

\hspace{10pt}	//close file\\
\hspace{10pt}	fclose(file);\\
}\\

pair$<$ int, int $>$ TGA::getMax(){\\
\hspace{10pt}	int max = 0;\\
\hspace{10pt}	int pi, pj;\\

\hspace{10pt}	for(int i = 0;i$<$this-$>$height;i++){\\
\hspace{10pt}\hspace{10pt}		for(int j = 0; j$<$this-$>$width; j++){\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			int pixel = i*this-$>$width + j;\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			int offset = pixel*3;\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			int suma = this-$>$data[offset+0] + this-$>$data[offset+1] + this-$>$data[offset+2];\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			if(suma $>$ max){\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}\hspace{10pt}				max = suma;\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}\hspace{10pt}				pi = i;\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}\hspace{10pt}				pj = j;\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			}\\
\hspace{10pt}\hspace{10pt}		}\\
\hspace{10pt}	}\\
\hspace{10pt}	int pixel = pi*this-$>$width + pj;\\
\hspace{10pt}	int offset = pixel*3;\\
\hspace{10pt}	pair$<$ int, int $>$ res(this-$>$height-pi, pj);\\
\hspace{10pt}	return res;\\
}\\

int TGA::getRadio(){\\
\hspace{10pt}	int pixeles = -1;\\
\hspace{10pt}	int tmp;\\
\hspace{10pt}	for(int i = 0;i$<$this-$>$height;i++){\\
\hspace{10pt}\hspace{10pt}		tmp = 0;\\
\hspace{10pt}\hspace{10pt}		for(int j = 0; j$<$this-$>$width; j++){\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			int pixel = i*this-$>$width + j;\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			int offset = pixel*3;\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			int suma = this-$>$data[offset+1] + this-$>$data[offset+2] + this-$>$data[offset+3];\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			if(suma $>$ 600){\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}\hspace{10pt}				tmp++;\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			}\\
\hspace{10pt}\hspace{10pt}		}\\

\hspace{10pt}\hspace{10pt}		if(tmp$>$=pixeles){\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			pixeles = tmp;\\
\hspace{10pt}\hspace{10pt}		}else{\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			return pixeles/2;\\
\hspace{10pt}\hspace{10pt}		}\\
\hspace{10pt}	}\\
\hspace{10pt}	return pixeles/2;\\
}\\

pair$<$ int, int $>$ TGA::getCentro(int radio){\\
\hspace{10pt}	int pi, pj;\\
\hspace{10pt}	int pimin = this-$>$height;\\
\hspace{10pt}	int pjmin = this-$>$width;\\
	
\hspace{10pt}	for(int i = 0;i$<$this-$>$height;i++){\\
\hspace{10pt}\hspace{10pt}		for(int j = 0; j$<$this-$>$width; j++){	\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			if (getPixel(i,j)[0] != 0){\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}\hspace{10pt}				if (pimin $>$ i){pimin=i;}\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}\hspace{10pt}				if (pjmin $>$ j){pjmin=j;}	\\
\hspace{10pt}\hspace{10pt}\hspace{10pt}			}			\\
\hspace{10pt}\hspace{10pt}		}\\
\hspace{10pt}	}	\\
\hspace{10pt}	pi = pimin+radio;\\
\hspace{10pt}	pj = pjmin+radio;\\
\hspace{10pt}	pair$<$ int, int $>$ res(pi, pj);\\
\hspace{10pt}	return res;\\
}\\


int* TGA::getPixel(int i, int j){\\
\hspace{10pt}	int pixel = i*this-$>$width + j;\\
\hspace{10pt}	int offset = pixel*3;\\
\hspace{10pt}	int* res = new int[3];\\
\hspace{10pt}	res[0] = this-$>$data[offset+0];\\
\hspace{10pt}	res[1] = this-$>$data[offset+1];\\
\hspace{10pt}	res[2] = this-$>$data[offset+2];\\
\hspace{10pt}	return res;\\
}\\
